import React, {Component} from 'react';
import styles from './index.less';
import CSSModules from 'react-css-modules';
import {withRouter} from 'react-router-dom';
import {List} from 'antd';
import {Link} from 'react-router-dom';
import CommentList from './CommentList';

import PageHeader from 'ant-design-pro/lib/PageHeader';
import {Button, Icon, Card, message, Col, Row, Form, Input} from 'antd';
const ButtonGroup = Button.Group,
  FormItem = Form.Item;

import {UPLOAD_URL, ARTICLE_URL} from 'constant/url';
import myaxios, {get, put, post, deleteAxios} from 'common/fetch';

class Comment extends Component {
  constructor(props) {
    super(props);
    this.state = {
      html: '',
      postDetail: {},
    };
  }
  componentDidMount() {
    const {match} = this.props;
    let postId = match.params.articleId;
    if (postId) {
      get(`/nnc/post/${postId}`).then(res => {
        let postDetail = res && res[0];
        this.setState({
          postDetail,
        });
      });
    }
  }
  render() {
    const {postDetail} = this.state,
          {match} = this.props;
    return (
      <div className={styles['home-wrap']}>
        <PageHeader
          title={
            <div style={{fontSize: 20, fontWeight: 500}}>
              {postDetail.title}
            </div>
          }
          breadcrumbList={[
            {
              title: '文章列表',
              href: '/article',
            },
            {
              title: '评论列表',
            },
          ]}
          linkElement={Link}
          className={styles.pageHeader}
        />
        <Card style={{margin: 24}} bordered={false}>
          <CommentList query={match.params} />
        </Card>
      </div>
    );
  }
}

//export default CSSModules(ArticleList, styles);
export default Comment;
